package lol.clann.bukkit.pluginboot.exampleconfig;

import com.google.common.collect.Maps;
import lol.clann.bukkit.pluginboot.model.ItemStackBuilder;
import lol.clann.clannboot.annotation.config.Configure;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 配置注入样例
 *
 * @author pyz
 * @date 2018/10/2 上午9:26
 */
// 只是例子,所以注释掉,不然运行时就真的加载了= =
//@Service
public class ExampleConfig {

    @Configure(value = "pluginboot.interval", comment = "间隔")
    public int interval = 3;

    @Configure(value = "pluginboot.message", comment = "消息")
    public String message = "asdsadsad";

    @Configure(value = "pluginboot.messages.list", comment = "集合注入")
    public List<String> messages1;

    @Configure(value = "pluginboot.messages.set", comment = "集合注入")
    public Set<String> messages2;

    @Configure(value = "pluginboot.messages.map", comment = "集合注入")
    public Map<String, String> messages3;

    @Configure(value = "pluginboot.messages.itemmap", comment = "ItemStack也可以")
    public Map<String, ItemStack> messages4;

    @Configure(value = "pluginboot.messages.itemmap", comment = "自定义的节点进行注入")
    public Map<String, ExampleNode> messages5;

    /**
     * 可以在构造函数中设置一些比较复杂的默认值
     */
    public ExampleConfig() {
        messages1 = Lists.newArrayList("1", "2", "3");
        messages2 = Sets.newHashSet("1", "2", "3");

        messages3 = Maps.newHashMap();
        messages3.put("1", "2");

        ItemStack exampleItem = ItemStackBuilder.builder().addLore("lore").material(Material.DIAMOND).displayName("血钻").build();

        messages4 = Maps.newHashMap();
        messages4.put("1", exampleItem);

        messages5 = Maps.newHashMap();
        messages5.put("first", new ExampleNode().setCount(1).setItemStack(exampleItem).setMessage("哈哈哈"));
    }
}
